﻿using Basic.FlowRemoteModel;
using Basic.FlowRemoteModel.FlowAuditInter.Model;
using Basic.OARemoteModel;
using Basic.OAService.Interface;
using WeDonekRpc.Client.Interface;

namespace Basic.OAService.RpcEvent
{
    internal class FlowAuditEvent : IRpcApiService
    {
        private readonly IDataFillInService _Service;

        public FlowAuditEvent ( IDataFillInService service )
        {
            this._Service = service;
        }

        public void BeginAudit ( AuditEventBody data )
        {
            this._Service.BeginAudit(data.LinkPk);
        }

        public void AuditEnd ( AuditEventBody data )
        {
            FillInStatus status = FillInStatus.起草;
            if ( data.AuditLog.AuditStatus == FlowAuditStatus.审核通过 )
            {
                status = FillInStatus.审核通过;
            }
            else if ( data.AuditLog.AuditStatus == FlowAuditStatus.审核未通过 )
            {
                status = FillInStatus.审核未通过;
            }
            this._Service.AuditEnd(data.LinkPk, status);
        }
    }
}
